package com.zxyankh.generator.math.practice.dto;

public class Problem {
	private int no;
	private int preNumber;
	private boolean add;
	private int sufNumber;
	private int answer;

	public int getNo() {
		return no;
	}

	public void setNo(int no) {
		this.no = no;
	}

	public int getPreNumber() {
		return preNumber;
	}

	public void setPreNumber(int preNumber) {
		this.preNumber = preNumber;
	}

	public boolean isAdd() {
		return add;
	}

	public void setAdd(boolean add) {
		this.add = add;
	}

	public int getSufNumber() {
		return sufNumber;
	}

	public void setSufNumber(int sufNumber) {
		this.sufNumber = sufNumber;
	}

	public int getAnswer() {
		return answer;
	}

	public void setAnswer(int answer) {
		this.answer = answer;
	}

	public void calculate() {
		if (this.isAdd()) {
			this.answer = this.preNumber + this.sufNumber;
		} else {
			this.answer = this.preNumber - this.sufNumber;
		}
	}

	@Override
	public String toString() {
		return no + ". " + preNumber + (add ? " + " : " - ") + sufNumber + " = " + answer;
	}
	
	public String toQuestion() {
		return no + ". " + preNumber + (add ? " + " : " - ") + sufNumber + " = ";
	}
	
	public String toAnswer() {
		return no + ". " + answer;
	}

}
